<?php
/**
 * Created by PhpStorm.
 * User: mac
 * Date: 2019-03-03
 * Time: 03:10
 */

$http = new swoole_http_server('127.0.0.1', 8080);

$http->on('request', function ($req, $res){
    //使用Redis协程客户端 Co 这是种短名称写法 要打开的话修改php.ini 加入swoole.use_shortname = On
    $redis = new Co\Redis();
    $redis->connect('127.0.0.1', 6379);
    $value = $redis->get($req->get['key']);

    $res->header("Content-Type", "text/html");
    $res->end($value);
});

$http->start();